using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using EntLibEC.Cmn;
using EntLibEC.Biz.Basic;
using EntLibEC.Info.Basic;

namespace EntLibEC.View.Basic
{
	/// <summary>
	/// Summary description for SysUserPrivilege.
	/// </summary>
	public partial class SysUserPrivilege : PageBase
	{

		private int sysno;
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			if ( Request.QueryString["sysno"] != null)
			{
				try
				{
					this.sysno = Convert.ToInt32(Request.QueryString["sysno"].ToString());
				}
				catch
				{
					Assert(lblMessage, "sysno is not an integer", -1);
					return;
				}
			}
			else
			{
				Assert(lblMessage, "sysno missing", -1);
			}
			BindGrid();
		}

		private void BindGrid()
		{
			DataTable dt = BuildTable();
			DataGrid1.DataSource = dt;
			DataGrid1.DataBind();
			int rows = 0;
			if ( Util.HasMoreRow(dt) )
				rows = dt.Rows.Count;
			Assert(lblMessage, rows.ToString() + " record(s)", 1);
		}
		private DataTable BuildTable()
		{
			DataTable table = new DataTable("Currency");
			table.Columns.Add(new DataColumn("SysNo",typeof(int)));
			table.Columns.Add(new DataColumn("PrivilegeID",typeof(string)));
			table.Columns.Add(new DataColumn("PrivilegeName",typeof(string)));
			
			Hashtable ht = SysManager.GetInstance().GetPrivilegeHtByUser(this.sysno);
			if ( ht == null )
				return table;

			foreach(PrivilegeInfo item in ht.Values)
			{
				DataRow row = table.NewRow();
				row["SysNo"] = item.SysNo;
				row["PrivilegeID"] = item.PrivilegeID;
				row["PrivilegeName"] = item.PrivilegeName;

				table.Rows.Add(row);

			}
			return table;

		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion
	}
}
